<?=view('header.html');?>

<body class="layui-view-body">
    <div class="layui-content">
        <div class="layui-row">
            <div class="layui-card">
                <div class="layui-card-header">
                    项目设置
                </div>
                <div class="layui-card-body">
                    <div class="form-box">
                        <form class="layui-form mokui-form" name="myform" lay-filter="myform" id="myform">

                            <div class="layui-tab layui-tab-card">
                                <ul class="layui-tab-title">
                                    <li class="layui-this">设置你的</li>
                                    <li>小程序设置</li>
                                </ul>
                                <div class="layui-tab-content">
                                    <!--1-->
                                    <div class="layui-tab-item layui-show">

                                        <div class="layui-form-item">
                                            <label class="layui-form-label">例子：</label>
                                            <div class="layui-input-inline">
                                                <input class="layui-input" type="text" name="data[lizi]" value="<?=$data['lizi'] ?? ''?>">
                                            </div>
                                            <span class="layui-form-mid layui-word-aux">例子</span>
                                        </div>

                                    </div>

                                    <!--2-->
                                    <div class="layui-tab-item">

                                        <div class="layui-form-item">
                                            <label class="layui-form-label">AppID：</label>
                                            <div class="layui-input-inline">
                                                <input class="layui-input" type="text" name="data[wxmini][appid]" value="<?=$data['wxmini']['appid'] ?? ''?>">
                                            </div>
                                            <span class="layui-form-mid layui-word-aux">微信小程序appid</span>
                                        </div>

                                        <div class="layui-form-item">
                                            <label class="layui-form-label">AppSecret：</label>
                                            <div class="layui-input-inline">
                                                <input class="layui-input" type="text" name="data[wxmini][appsecret]" value="<?=$data['wxmini']['appsecret'] ?? ''?>">
                                            </div>
                                            <span class="layui-form-mid layui-word-aux">微信小程序密钥</span>
                                        </div>

                                    </div>


                                </div>

                                <div class="layui-form-item">
                                    <label class="layui-form-label"></label>
                                    <div class="layui-input-block">
                                        <button class="layui-btn layui-btn-blue" lay-submit="" lay-filter="ams_submit">提交保存</button>
                                    </div>
                                </div>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
</body>
<?=view('footer.html');?>
<script type="text/javascript">
    layui.use(['layer', 'form', 'jquery', 'element'], function () {
        var layer = layui.layer,
            $ = layui.jquery,
            form = layui.form,
            element = layui.element;

        form.on('submit(rateCount)', function (data) {

            var money = $("#money").val();
            if (!money) {
                layer.msg('请输入购买价格');
                return false;
            }

            var level1 = parseFloat(data.field['data[rebate][1]']),
                level2 = parseFloat(data.field['data[rebate][2]']),
                level3 = parseFloat(data.field['data[rebate][3]']),
                result = '';

            result = '一级(经销商)获得:' + parseFloat(money * (level1 / 100)).toFixed(2) + '元,二级(用户A)获得:' + parseFloat(money * (level2 / 100)).toFixed(2) + ' 元,三级(用户B)获得:' + parseFloat(money * (level3 / 100)).toFixed(2) + '元.';
            result += '<br>本次总返利金额:' + parseFloat(money * ((level1 + level2 + level3) / 100)).toFixed(2);

            $("#result").html(result);

            return false;
        });
        //水印方式
        form.on('radio(ams_set_mw_type)', function (data) {
            var id = data.value;
            $(".ams_mw_1").hide();
            $(".ams_mw_0").hide();
            $(".ams_mw_" + id).show();
            form.render();
        });
        //提交
        form.on('submit(ams_submit)', function (data) {
            $.post(adminpath + "admin/system/program", data.field, function (res) {
                if (res.code == 0) {
                    layer.msg('操作成功， 正在刷新...', { time: 1000 }, function () {
                        location.reload();
                    });
                } else {
                    layer.msg(res.msg, { icon: 5 });
                }
            }, 'json');
            return false;
        });
    });
</script>